package xiu_xiu.base;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.TextView;

import com.xiu_xiu.R;

import org.xutils.x;

import java.util.ArrayList;

import xiu_xiu.view_A_main.AAA;

/**
 * Created by 阳 on 2016/4/1.
 */
public class BaseActivity extends AppCompatActivity {


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);



    }

    @Override
    public void setContentView(int layoutResID) {
        super.setContentView(layoutResID);
        //初始化 xutils3,
        x.view().inject(this);
    }












    /**
     * 标题回退键响应
     */
    public void setBackArrows(View back) {

        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }

    /**
     * 跳转到搜索页面
     */
    public void skipSearchActivity(final Context context, View serch) {

        serch.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(context, AAA.class);
                startActivity(intent);
                finish();
            }
        });

    }



    /**
     * 设置标题与返回搜索按钮的显示,名字最多传入4个
     *
     * @param back   设置返回按钮是否显示
     * @param search 设置探索按钮是否显示
     */
    public void setTitleMore(int back, int search, String title1, String title2, String title3, String title4) {
        ArrayList<TextView> textViewts = new ArrayList<TextView>();
        ArrayList<String> title = new ArrayList<String>();

        findViewById(R.id.bar_top_conver_classify_back).setVisibility(back);
        findViewById(R.id.im_bar_top_conver_classify_search).setVisibility(search);

        title.add(title1);
        title.add(title2);
        title.add(title3);
        title.add(title4);

        textViewts.add((TextView) findViewById(R.id.tv_bar_top_conver_classify_title1));
        textViewts.add((TextView) findViewById(R.id.tv_bar_top_conver_classify_title2));
        textViewts.add((TextView) findViewById(R.id.tv_bar_top_conver_classify_title3));
        textViewts.add((TextView) findViewById(R.id.tv_bar_top_conver_classify_title4));

        for (int i = 0; i < textViewts.size(); i++) {
            if (title.get(i) != null) {

                textViewts.get(i).setText(title.get(i));
            } else {
                textViewts.get(i).setVisibility(View.GONE);
            }
        }

    }

}
